package com.admin.controller;

import java.util.ArrayList;
import java.util.List;

import com.admin.controller.from.FunctionFromBean;
import com.admin.model.Sys_Function;
import com.admin.model.Sys_User;
import com.admin.util.Constants;

public class MainController extends BaseController {
	public void index() {
		Sys_User user = getSessionAttr(Constants.LOGIN_USER);
		List<Sys_Function> sf = Sys_Function.dao.find(new String[]{"parent=0","del=0","id in ("+ Sys_Function.dao.getFunByUserId(user.getLong("id")) +")"},new String[]{"sort"},null);
		List<FunctionFromBean> ffbs = new ArrayList<FunctionFromBean>();
		for (Sys_Function s : sf) {
			FunctionFromBean bean = new FunctionFromBean();
			bean.setSf(s);//父级菜单
			bean.setSfs(Sys_Function.dao.find(new String[]{"parent="+s.getLong("id"),"del=0","id in ("+ Sys_Function.dao.getFunByUserId(user.getLong("id")) +")"},new String[]{"sort"},null));//子菜单
			ffbs.add(bean);
		}
		setAttr("functions",ffbs);
		this.render("/jsp/main/index.jsp");
	}

	public void loadMenu() {

	}
}
